﻿using Anke.SHManage.BLL;
using Anke.SHManage.MSSQLDAL.TJDAL;
using Anke.SHManage.Utility;
using Microsoft.Reporting.WebForms;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Anke.SHManage.Web.Reports
{
    public partial class RSJXModeWebForm : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
             if (!IsPostBack)
            {
                InitPage();
            }
        }
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            BindReportDataSource();

        }
        private void InitPage()
        {
            this.StartDate.Text = DateTime.Now.AddDays(1 - DateTime.Now.Day).ToString("yyyy-MM-dd");
            this.EndDate.Text = DateTime.Now.AddDays(1).ToString("yyyy-MM-dd");
            BindReportDataSource();
        }

        protected void BindReportDataSource()
        {
            DateTime start = Convert.ToDateTime(this.StartDate.Text);
            DateTime end = Convert.ToDateTime(this.EndDate.Text);       
            string centerID = (this.centerID.Text).ToString();
            string stationID = (this.stationID.Text).ToString();
            string actualCode = (this.actualCode.Text).ToString();
            string ambulanceNumber = (this.ambulanceNumber.Text).ToString();
            string driver = (this.Driver.Text).ToString();
            string doctor = (this.Doctor.Text).ToString();
            string nurse = (this.Nurse.Text).ToString();
            string stretcher = (this.Stretcher.Text).ToString();          
            string start1 = start.ToString();
            string end1 = end.ToString();
         
            this.ReportViewer1.LocalReport.DataSources.Clear();
            this.ReportViewer1.LocalReport.ReportPath = Server.MapPath(@"~/Reports/TJ_RSJX.rdlc");
            Microsoft.Reporting.WebForms.ReportParameter st = new Microsoft.Reporting.WebForms.ReportParameter("StartTime", start1);
            Microsoft.Reporting.WebForms.ReportParameter ed = new Microsoft.Reporting.WebForms.ReportParameter("EndTime", end1);
            this.ReportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter[] { st, ed });
            TJDAL dal = new TJDAL();
            DataTable dt = dal.Get_TJ_RSJX(start, end, centerID, stationID, actualCode, ambulanceNumber,
                                            driver, doctor, nurse, stretcher);   
                                                 
            this.ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSetForTJ_RSJX", dt));
            this.ReportViewer1.LocalReport.Refresh();
        }
    }       
    
}